package com.trkj.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.trkj.pojo.Emp;
import com.trkj.service.TransferService;
import com.trkj.vo.TransferVo;
/**
 * 调动Controller
 * @author 彭帅
 *
 */
@Controller
@Transactional
@SessionAttributes({"emp", "funcIds"})
public class TransferController {
	@Autowired
	TransferService transferService;
	/**
	 * 填写调动申请单
	 * @return
	 */
	@RequestMapping("/to_transfer")
	public String to_transfer() {
		return "to_transfer";
	}
	
	/**
	 * 表单部门下拉框数据
	 * @return
	 */
	@RequestMapping("/findAll_dept")
	public @ResponseBody List<Map<String, Object>> findAll_dept() {
		return transferService.findAllDept();
	}
	
	/**
	 * 调动前部门表单下拉数据
	 * @return
	 */
	@RequestMapping("/findBeforeDept")
	public @ResponseBody Map<String, Object> findBeforeDept(Integer empId) {
		return transferService.findOneDept(empId);
	}
	
	/**
	 * 表单员工下拉框数据
	 * @return
	 */
	@RequestMapping("/findAll_emp")
	public @ResponseBody List<Map<String, Object>> findAll_emp() {
		return transferService.findAll_emp_combobox();
	}
	
	/**
	 * 获取调动信息
	 * @param model
	 * @return
	 */
	@RequestMapping("/get_transfer")
	@ResponseBody
	public TransferVo get_transfer(Model model) {
		Emp emp = (Emp) model.asMap().get("emp");
		Integer empid = emp.getEmpId();
		return transferService.transferVo(empid);
	}
	
	/*@RequestMapping("/findDeptName")
	public @ResponseBody List<Map<String, Object>> findDeptName(Integer empid) {
		return transferService.findDeptName(empid);
	}*/
	
}
